home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
shells
/
kiss-0.11
/
kiss-0
/
kiss
/
src
/
getprompt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-23
|
777b
|
55 lines
#include "kiss.h"
char *getprompt ()
{
register char
*prompt,
*cwd;
static char
buf [LINELEN];
char
twobuf [2] = { 0, 0 };
cwd = getcwd (NULL, 0);
if (! flags.noenviron)
addtoenv ("PWD", cwd);
if (! (prompt = getenv ("PROMPT")) )
prompt = "[%u] %p > ";
buf [0] = '\0';
while (*prompt)
{
if (*prompt == '%' && *(prompt + 1))
{
prompt++;
switch (*prompt)
{
case 'n':
strcat (buf, "\n");
break;
case 'u':
strcat (buf, username);
break;
case 'p':
strcat (buf, cwd);
break;
default:
twobuf [0] = *prompt;
strcat (buf, twobuf);
}
}
else
{
twobuf [0] = *prompt;
strcat (buf, twobuf);
}
prompt++;
}
free (cwd);
return (buf);
}